package algotithm.jianzhioffer.test48;

import java.util.*;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/13-11:34
 */
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int res = 0;
        HashMap<Integer, Integer> map = new HashMap<>(20);
        for (int i = 0, j = 0; i < n; i++) {
            map.put(arr[i],map.getOrDefault(arr[i],0) + 1);
            while (map.get(arr[i]) > 1) {
                map.put(arr[j],map.get(arr[j])-1);
                j++;
            }
            res = Math.max(res,i - j + 1);
        }
        System.out.println(res);
    }
}
